import java.util.Calendar;
import java.util.Vector;

/**
 * This will contain all helper method. everything here must be public static
 */
public class Helper {
	/**
	 * Convert string representation of date to Calendar
	 * @param date string representation of date
	 * @return Calendar representation of date
	 */
	public static Calendar strToCal(String date){
		String dateFields[] = date.split("/");
		Calendar c = Calendar.getInstance();
		c.set(Integer.parseInt(dateFields[0]), Integer.parseInt(dateFields[1])-1, Integer.parseInt(dateFields[2]));

		return c;
	}

	/**
	 * Convert Calendar representation of date to String representation
	 * @param c Calendar representation of date
	 * @return String representation of date
	 */
	public static String calToStr(Calendar c){
		String str = c.get(Calendar.DAY_OF_MONTH) + "";
		str = (c.get(Calendar.MONTH)+1) + "/" + str;
		str = c.get(Calendar.YEAR) + "/" + str;

		return str;
	}

	
	
	
	
	//multiple printAll() for different class
	public static void printAll(Profile myProfile){
		System.out.printf("Profile.name: %s\n", myProfile.getName());
		System.out.printf("Profile.counter: %d\n", myProfile.getCounter());
		printAll(myProfile.getWallet());
	}
	
	public static void printAll(Wallet wallet){
		
		System.out.printf("Wallet.balance: %s\n", wallet.getBalance().toString());
		System.out.printf("Wallet.itemIndex: %d\n", wallet.getItemIndex());
		printAll(wallet.getSalary());
		printAll(wallet.getAlert());
		
		//get 3 list.
		Vector<Expense> exList = wallet.getExpenseList();
		Vector<Income> inList = wallet.getIncomeList();
		Vector<Bill> billList = wallet.getBillList();

		System.out.printf("Wallet.ExpenseList =============================\n");
		for(Expense e : exList){
			System.out.printf("Desc: %s; Date: %s; amt: %s; category: %s; pmethod: %s\n", 
					e.getDescription(), Helper.calToStr(e.getDate()), e.getAmt().toString(), e.getCategory(), e.getPaymentMethod() );
		}
		System.out.printf("Wallet.IncomeList =============================\n");
		for(Income i : inList){
			System.out.printf("Desc: %s; Date: %s; amt: %s\n", 
					i.getDescription(), Helper.calToStr(i.getDate()), i.getAmt().toString() );
		}
		System.out.printf("Wallet.BillList =============================\n");
		for(Bill b : billList){
			System.out.printf("Desc: %s; Date: %s; lastPaid: %s\n", 
					b.getDescription(), Helper.calToStr(b.getDate()), Helper.calToStr(b.getLastPaidDate()) );
		}
	}
	
	public static void printAll(Salary salary){
		System.out.printf("salaAmt: %s, salaNextDate: %s, salaLastDate: %s, salaIndex: %d\n", 
				salary.getAmt().toString(), calToStr(salary.getNextPayDate()), calToStr(salary.getLastPaidDate()), salary.getIndex());
	}
	
	public static void printAll(Alert alert){
		System.out.println("printing alert is a stub");
	}




	

}
